package org.example.service;

import org.example.R.R;
import org.example.entity.dto.EditBasicInformationDto;
import org.example.entity.vo.BasicInformationVO;
import org.example.entity.vo.admin.*;
import org.example.entity.vo.pc.PCBaseInfoVo;
import org.example.mapper.BaseInfoMapper;
import org.example.mapper.BasicMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class BaseInfoService {

    @Autowired
    private BaseInfoMapper baseInfoMapper;

    @Autowired
    private BasicMapper basicMapper;

    public R detail() {
        BasicInformationVO infoDetail = baseInfoMapper.infoDetail();

        return R.success("成功").setData(infoDetail);
    }

    public R pcDetail() {
        List<PCBaseInfoVo> result =new ArrayList<>();
        BasicInformationVO infoDetail = baseInfoMapper.infoDetail();
        PCBaseInfoVo vo1 = new PCBaseInfoVo();
        PCBaseInfoVo vo2 = new PCBaseInfoVo();
        PCBaseInfoVo vo3 = new PCBaseInfoVo();
        PCBaseInfoVo vo4 = new PCBaseInfoVo();
        PCBaseInfoVo vo5 = new PCBaseInfoVo();
        PCBaseInfoVo vo6 = new PCBaseInfoVo();
        PCBaseInfoVo vo7 = new PCBaseInfoVo();
        PCBaseInfoVo vo8 = new PCBaseInfoVo();
        PCBaseInfoVo vo9 = new PCBaseInfoVo();
        PCBaseInfoVo vo10 = new PCBaseInfoVo();

//        vo1.setName("户籍人口");
//        vo1.setValue(infoDetail.getRegisteredResidencePopulation());
//        vo2.setName("常住人口");
//        vo2.setValue(infoDetail.getPermanentResidencePopulation());
//        vo4.setName("公益岗成员");
//        vo4.setValue(infoDetail.getPublicWelfarePostNumberMember());
//        vo5.setName("村“两委员”成员");
//        vo5.setValue(infoDetail.getVillageCommitteeMember());
//        vo3.setName("党员");
//        vo3.setValue(infoDetail.getPartyMember());
//        vo6.setName("入党积极分子");
//        vo6.setValue(infoDetail.getJoiningTheActivistMember());
//        vo7.setName("预备党员");
//        vo7.setValue(infoDetail.getProbationaryPartyMember());
//        vo8.setName("后备干部");
//        vo8.setValue(infoDetail.getReserveCadreMember());
//        vo9.setName("退役军人");
//        vo9.setValue(infoDetail.getVeteransMember());
//        vo10.setName("特殊人群");
//        vo10.setValue(infoDetail.getSpecialPopulationMember());

        result.add(vo1);
        result.add(vo2);
        result.add(vo3);
        result.add(vo4);
        result.add(vo5);
        result.add(vo6);
        result.add(vo7);
        result.add(vo8);
        result.add(vo9);
        result.add(vo10);

        return R.success("成功").setData(result);
    }

    public R edit(EditBasicInformationDto dto) {
        baseInfoMapper.edit(dto);
        return R.success("修改成功!");
    }

    public R showDetail() {
        List<PCBaseInfoVo> result =new ArrayList<>();


        List<村两委信息> 村两委信息List = basicMapper.list村两委信息();
        List<户籍人口信息> 户籍人口信息s = basicMapper.list户籍人口信息();
        List<退役军人> 退役军人s = basicMapper.list退役军人();
        List<公益岗名单> 公益岗名单s = basicMapper.list公益岗名单();
        List<享受脱贫政策户名单> 享受脱贫政策户名单s = basicMapper.list享受脱贫政策户名单();
        List<低保人员名单> 低保人员名单s = basicMapper.list低保人员名单();

        PCBaseInfoVo vo1 = new PCBaseInfoVo();
        PCBaseInfoVo vo2 = new PCBaseInfoVo();
        PCBaseInfoVo vo3 = new PCBaseInfoVo();
        PCBaseInfoVo vo4 = new PCBaseInfoVo();
        PCBaseInfoVo vo5 = new PCBaseInfoVo();
        PCBaseInfoVo vo6 = new PCBaseInfoVo();

        vo1.setName("村“两委”信息");
        vo1.setValue(村两委信息List.size());
        vo2.setName("户籍人口");
        vo2.setValue(户籍人口信息s.size());
        vo3.setName("退役军人");
        vo3.setValue(退役军人s.size());
        vo4.setName("公益岗成员");
        vo4.setValue(公益岗名单s.size());
        vo5.setName("享受脱贫政策户");
        vo5.setValue(享受脱贫政策户名单s.size());
        vo6.setName("低保户");
        vo6.setValue(低保人员名单s.size());

        result.add(vo1);
        result.add(vo2);
        result.add(vo3);
        result.add(vo4);
        result.add(vo6);
        result.add(vo5);
        return R.success("成功").setData(result);
    }
}
